package com.dynamictpm.config;

import com.dynamictpm.service.ConfigServletInner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.AsyncContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLDecoder;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
 * Description：初始化控制器
 *
 * PackageName： com.dynamictpm.config
 * ClassName：ConfigController
 *
 *
 * @author：it-yml CreateTime：2023-07-01
 * -----------------------------
 */
@RestController
@RequestMapping("config")
public class ConfigController {

    @Autowired
    private ConfigServletInner configServletInner;

    @PostMapping("/listener")
    public void listener(HttpServletRequest request, HttpServletResponse response) {
        request.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true);
        long timeout = Math.max(10000, Long.parseLong("3000") - 500);


        configServletInner.doPollingConfig(request, response);

    }

}
